Many types of programming languages exist. One form of programming language is a scripting language. A scripting language is a programming language that enables control of one or more applications. A “script”, or program generated according to a scripting language, may be written in a same language or a different language from that of an associated application. While applications are typically first compiled to native machine code, scripts are often interpreted from source code.
Another form of programming language is a dynamic programming language. A dynamic programming language is a programming language that performs some behaviors during runtime that other programming languages (that are not dynamic) may perform during compilation. Such behaviors may include extending a program by adding new code, extending objects and definitions, and/or modifying the type system. Many scripting programming languages are also dynamic programming languages.
A web browser is an application for rendering web pages for display. Scripts are frequently run on web pages in order to dynamically change their content. Client-side scripting generally refers to scripts that are executed client-side by a web browser rather than being executed server-side on a web server. Client-side scripting can make web pages more responsive to user input by avoiding one or more round trip communications with the web server.
Scripts written in dynamic programming languages are difficult to execute efficiently. For instance, ECMAScript (a scripting language standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262) is an example dynamic programming language used in scripts that is very flexible. In many ECMAScript programs, only a portion of the ECMAScript code is executed, and an even smaller portion of the ECMAScript code is run during the program start-up. As such, parsing of the entire code base unnecessarily delays the start of execution. In addition, most code actually written in ECMAScript does not exploit the full range of the ECMAScript language's flexibility. However, the machine code generated by an ECMAScript compiler is generated to correctly handle a wide spectrum of possibilities at runtime, which results in inefficient execution.
Systems exist that optimize the manner in which scripts written in dynamic programming languages are executed, so that such scripts may be executed more efficiently. For example, commonly-owned co-pending U.S. patent application Ser. No. 13/229,594 to Lafreniere et al., entitled “Profile Guided JIT Code Generation” and filed on Sep. 9, 2011, describes a runtime engine that is configured to execute a script and to collect and store profile data concerning the script during such execution. The runtime engine is further configured to use such profile data to perform just-in-time (JIT) compilation of selected portions of the script. The JIT-compiled portions of the script are then used to execute the script in a more efficient manner than if the script were executed only by a script interpreter. Still other systems may exist that can optimize the execution of a script (or other code) based on profile data that is collected during execution thereof.
The aforementioned profile data represents a sample of the script's historical behavior. It does not necessarily represent what the script will do in the future. Thus, any optimizations applied to the manner of execution of the script based on the profile data must be implemented in such a manner that the optimizations will behave correctly even if the script's behavior changes. For example, changes in the behavior of the script should not cause program crashes or incorrect functional behavior. It would be beneficial, then, if the applied optimizations could be tested at a point when the script is behaving in a manner that deviates from the pattern of behavior represented by the profile data.
Most scripts, however, do not significantly change their behavior from when profile data is collected to when optimizations based on such profile data have been applied. This makes application of certain testing techniques less useful in verifying that the system for optimizing script execution is behaving correctly. For example, a web crawler may be used to test the system for optimizing script execution by causing the system to execute scripts included within a series of sequentially-accessed web pages. However, it has been observed that most web page scripts do not significantly change their behavior from when profile data about such scripts is collected to when optimizations based on such profile data have been applied.